package com.example.demo02.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo02.mapper.InventoryRecordMapper;
import com.example.demo02.entity.InventoryRecord;
import com.example.demo02.service.InventoryRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * (InventoryRecord)表服务实现类
 *
 * @author makejava
 * @since 2024-09-01 21:10:45
 */
@Service("inventoryRecordService")
public class InventoryRecordService extends ServiceImpl<InventoryRecordMapper, InventoryRecord>{


    @Autowired
    private InventoryRecordMapper inventoryRecordMapper;
    @Autowired
    private ProductService productService;

    @Transactional
    public Integer addInventoryRecord(InventoryRecord inventoryRecord) {
        productService.increaseStock(inventoryRecord.getProductId(), inventoryRecord.getQuantity());
        inventoryRecordMapper.insert(inventoryRecord);
        return inventoryRecord.getRecordId();
    }


}



